package com.chinadci.smartcommunitysystembackstage.controller;


import com.chinadci.smartcommunitysystembackstage.entity.ScsOutsiders;
import com.chinadci.smartcommunitysystembackstage.service.ScsActivityService;
import com.chinadci.smartcommunitysystembackstage.service.ScsOutsidersService;
import com.chinadci.smartcommunitysystembackstage.util.DateTime;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Code Duck
 * @since 2021-04-13
 */
@CrossOrigin
@RestController
@Api("建业E家")
public class ScsOutsidersController {
    @Autowired
    private ScsOutsidersService service;

    //显示所有外来临时人员
    @ApiOperation(value = "显示所有外来临时人员")           //swagger
    @ApiImplicitParam(name = "name",value = "外来人员姓名")       //表明要传入的参数
    @RequestMapping(value = "/api/wlry",method = RequestMethod.GET)
    public Map Finds(String name){
        Map<String,Object> map=new HashMap<>();
        if (name!=null & name!=""){
            map.put("data",service.Find(name));
        }else{
            map.put("data",service.Find());
        }
        return map;
    }

    //登记外来临时人员
    @ApiOperation(value = "登记外来临时人员")           //swagger
    @ApiImplicitParam(name = "ScsOutsiders",value = "对象")       //表明要传入的参数
    @RequestMapping(value = "/api/djwlry",method = RequestMethod.POST)
    public Map Insert(ScsOutsiders scs){
        Map<String,Object> map=new HashMap<>();
        scs.setOCreateTime(DateTime.GetTime());
        map.put("data",service.Insert(scs));
        return map;
    }
}
